package com.hyz.config;

import com.hyz.dto.ActionResult;
import com.hyz.dto.ListResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author HGD
 */

@Slf4j
//@RestControllerAdvice
public class WebExceptionAdvice {

    @ExceptionHandler(RuntimeException.class)
    public ListResult listHandleRuntimeException(RuntimeException e) {
        log.error(e.toString(), e);
        return ListResult.fail("服务器异常");
    }

    @ExceptionHandler(RuntimeException.class)
    public ActionResult actionHandleRuntimeException(RuntimeException e) {
        log.error(e.toString(), e);
        return ActionResult.fail("服务器异常");
    }
}
